package org;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.opensymphony.xwork2.ActionSupport;

import vo.Custom;

public class LoginAction extends ActionSupport {
	private String customname;
	private String password;

	public String getCustomname() {
		return customname;
	}

	public void setCustomname(String customname) {
		this.customname = customname;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return
	 */
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
			SessionFactory sf = new Configuration().configure()
					.buildSessionFactory();
			Session session = sf.openSession();
			session.beginTransaction();
			Custom custom = new Custom();
			custom.setCustomname(getCustomname());
			custom.setPassword(getPassword());
			session.saveOrUpdate(custom);
			session.getTransaction().commit();
			session.close();
			return "success";
	}
}
